﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;


public partial class backmanage_API_A_Userquestion : System.Web.UI.Page
{
    /// <summary>
    /// USERSYSTEM QUESTION.API 用户系统API
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Expires = -1;
        string returnStr = string.Empty;
        string editType = Request.Params["edit"].ToString();//操作类型
        switch (editType)
        {
            case "add":
                {
                    returnStr = QuestionAdd();
                    break;
                }
            case "del":
                {
                    returnStr = QuestionDel();
                    break;
                }
            case "list":
                {
                    returnStr = QuestionList();
                    break;
                }
            default: break;
        }
        Response.Write(returnStr);
    }
    /// <summary>
    /// 添加密保问题
    /// </summary>
    /// <returns></returns>
    protected string QuestionAdd()
    {
        MODEL.UserQuestion model = new MODEL.UserQuestion();
        BLL.UserQuestion bll = new BLL.UserQuestion();
        model.Uquestion = Request.Params["q"].ToString();
        model.Ustate = true;

        return bll.UserQuestionAdd(model).ToString();
    }
    /// <summary>
    /// 删除密保问题
    /// </summary>
    /// <returns></returns>
    protected string QuestionDel()
    {
        int questionId = Convert.ToInt32(Request.Params["id"]);
        BLL.UserQuestion bll = new BLL.UserQuestion();

        return bll.UserQuestionDel(questionId).ToString();
    }
    /// <summary>
    /// 密保列表
    /// </summary>
    /// <returns></returns>
    protected string QuestionList()
    {
        BLL.UserQuestion bll = new BLL.UserQuestion();
        StringBuilder htmlStr = new StringBuilder();
        DataSet ds = bll.UserQuestionList();
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            htmlStr.Append("<tr id=\"" + ds.Tables[0].Rows[i]["Uid"].ToString() + "\">");
            htmlStr.Append("<td>" + ds.Tables[0].Rows[i]["Uid"].ToString() + "</td>");
            htmlStr.Append("<td>" + ds.Tables[0].Rows[i]["Uquestion"].ToString() + "</td>");
            htmlStr.Append("<td><a href=\"#\" class=\"del\" title=\"" + ds.Tables[0].Rows[i]["Uid"].ToString() + "\">删除</a></td>");
            htmlStr.Append("</tr>");
        }

        return htmlStr.ToString();
    }
}
